package cn.codeforfun.prize;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by Administrator on 2017/2/15 0015.
 */
@Service
@Transactional
public class PrizeService {
    @Autowired
    private PrizeDao prizeDao;

    public void save(Prize prize) {
        if (prize.getId() == null) {
            prize.setExchanged(0);
        }
        prizeDao.save(prize);
    }

    public List<Prize> findAll() {
        return prizeDao.findAll();
    }


    public Prize findOne(Long id) {
        return prizeDao.findOne(id);
    }
}
